import request from "@/utils/request";
/**
 * 文件上传
 * @param {*} data
 * @param {*} progressCallback
 * @returns
 */
export function uploadFile(data, progressCallback) {
  return request({
    url: "/juan/file/upload",
    method: "post",
    data: data,
    headers: { "Content-Type": "multipart/form-data" },
    onUploadProgress: (progressEvent) => {
      if (progressCallback && typeof progressCallback === "function") {
        progressCallback(progressEvent);
      }
      // let num = ((progressEvent.loaded / progressEvent.total) * 100) | 0; //百分比
      // file.onProgress({ percent: num }); //进度条
    },
    timeout: 5 * 60 * 1000,
  });
}
